﻿using System;
using System.Collections.Generic;


namespace Having.Site.Data
{
    /// <summary>
    /// 分页的接口
    /// </summary>
    public interface ICurPage
    {
        /// <summary>
        /// 符合条件的条数
        /// </summary>
        int total { set; get; }
        /// <summary>
        /// 返回的数据行
        /// </summary>
        dynamic rows { set; get; }
        /// <summary>
        /// 其他数据
        /// </summary>
        Dictionary<string, dynamic> otherdatas { set; get; }
    }

    /// <summary>
    /// 返回分页
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public interface ICurPage<T>: ICurPage
    {
        /// <summary>
        /// 类型一般是List
        /// </summary>
        new  T rows { set; get; }
    }
    /// <summary>
    /// 分页
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class BaseCurPage<T>: ICurPage<T>
    {
        /// <summary>
        /// 总条数
        /// </summary>
        public int total { set; get; }

        /// <summary>
        /// 当前页的数据集(List集合)
        /// </summary>
        public T rows { set; get; }

        /// <summary>
        /// 辅佐数据
        /// </summary>
        public Dictionary<string, dynamic> otherdatas { set; get; }
        object ICurPage.rows { get { return this.rows; } set { this.rows = (T)value; } }
    }
    /// <summary>
    /// 返回分页
    /// </summary>
    public class CurPage : BaseCurPage<object>, ICurPage
    {
        
    }
    /// <summary>
    /// 返回分页
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class CurPage<T> :  BaseCurPage<List<T>>, ICurPage<List<T>> where T:class, new()
    {
    }
}
